// Mock数据定义
export interface ContentItem {
  id: string
  title: string
  type: 'article' | 'video' | 'audio' | 'image'
  status: 'draft' | 'published' | 'reviewing'
  author: string
  createTime: string
  views: number
  likes: number
  shares: number
}

export interface PublishChannel {
  id: string
  name: string
  type: 'wechat' | 'weibo' | 'douyin' | 'website'
  status: 'active' | 'inactive'
  followers: number
  todayViews: number
}

export interface UserProfile {
  id: string
  name: string
  role: 'farmer' | 'village_admin' | 'government' | 'enterprise'
  village: string
  phone: string
  lastLogin: string
}

export interface StatisticData {
  date: string
  contentCount: number
  userCount: number
  viewCount: number
  interactionCount: number
}

// Mock数据
export const mockContentData: ContentItem[] = [
  {
    id: '1',
    title: '春季水稻种植技术指南',
    type: 'article',
    status: 'published',
    author: '张技术员',
    createTime: '2024-03-15',
    views: 1250,
    likes: 89,
    shares: 45
  },
  {
    id: '2',
    title: '特色农产品直播带货',
    type: 'video',
    status: 'published',
    author: '李主播',
    createTime: '2024-03-14',
    views: 3560,
    likes: 234,
    shares: 167
  },
  {
    id: '3',
    title: '乡村旅游景点介绍',
    type: 'image',
    status: 'reviewing',
    author: '王导游',
    createTime: '2024-03-13',
    views: 0,
    likes: 0,
    shares: 0
  }
]

export const mockPublishChannels: PublishChannel[] = [
  {
    id: '1',
    name: '乡村发展公众号',
    type: 'wechat',
    status: 'active',
    followers: 12500,
    todayViews: 2345
  },
  {
    id: '2',
    name: '乡村微博',
    type: 'weibo',
    status: 'active',
    followers: 8900,
    todayViews: 1567
  },
  {
    id: '3',
    name: '抖音乡村号',
    type: 'douyin',
    status: 'inactive',
    followers: 23400,
    todayViews: 0
  }
]

export const mockUserProfiles: UserProfile[] = [
  {
    id: '1',
    name: '张三',
    role: 'farmer',
    village: '幸福村',
    phone: '138****1234',
    lastLogin: '2024-03-15 14:30'
  },
  {
    id: '2',
    name: '李四',
    role: 'village_admin',
    village: '幸福村',
    phone: '139****5678',
    lastLogin: '2024-03-15 09:15'
  },
  {
    id: '3',
    name: '王五',
    role: 'government',
    village: '全县',
    phone: '137****9012',
    lastLogin: '2024-03-14 16:45'
  }
]

export const mockStatisticData: StatisticData[] = [
  { date: '2024-03-01', contentCount: 45, userCount: 123, viewCount: 2345, interactionCount: 567 },
  { date: '2024-03-02', contentCount: 52, userCount: 145, viewCount: 2678, interactionCount: 623 },
  { date: '2024-03-03', contentCount: 48, userCount: 156, viewCount: 2890, interactionCount: 712 },
  { date: '2024-03-04', contentCount: 61, userCount: 167, viewCount: 3123, interactionCount: 845 },
  { date: '2024-03-05', contentCount: 55, userCount: 178, viewCount: 2987, interactionCount: 789 },
  { date: '2024-03-06', contentCount: 67, userCount: 189, viewCount: 3456, interactionCount: 923 },
  { date: '2024-03-07', contentCount: 59, userCount: 195, viewCount: 3210, interactionCount: 856 }
]

// Mock API函数
export const mockApi = {
  // 获取内容列表
  getContentList: (): Promise<ContentItem[]> => {
    return new Promise((resolve) => {
      setTimeout(() => resolve(mockContentData), 500)
    })
  },

  // 获取发布渠道
  getPublishChannels: (): Promise<PublishChannel[]> => {
    return new Promise((resolve) => {
      setTimeout(() => resolve(mockPublishChannels), 500)
    })
  },

  // 获取用户数据
  getUserProfiles: (): Promise<UserProfile[]> => {
    return new Promise((resolve) => {
      setTimeout(() => resolve(mockUserProfiles), 500)
    })
  },

  // 获取统计数据
  getStatisticData: (): Promise<StatisticData[]> => {
    return new Promise((resolve) => {
      setTimeout(() => resolve(mockStatisticData), 500)
    })
  },

  // 模拟登录
  login: (username: string, password: string): Promise<{ success: boolean; message: string; isAdmin?: boolean }> => {
    return new Promise((resolve) => {
      setTimeout(() => {
        // Mock用户账号数据
        const mockUsers = [
          { username: 'admin', password: '123456', isAdmin: true, name: '系统管理员' },
          { username: 'user1', password: '123456', isAdmin: false, name: '张三' },
          { username: 'user2', password: '123456', isAdmin: false, name: '李四' },
          { username: 'farmer', password: '123456', isAdmin: false, name: '王五' },
          { username: 'village', password: '123456', isAdmin: false, name: '赵六' }
        ]
        
        const user = mockUsers.find(u => u.username === username && u.password === password)
        
        if (user) {
          resolve({ success: true, message: '登录成功', isAdmin: user.isAdmin })
        } else {
          resolve({ success: false, message: '用户名或密码错误' })
        }
      }, 1000)
    })
  }
}